//
//  ViewController.m
//  OpenCV-AnimalRecognize
//
//  Created by wjj on 14-10-27.
//  Copyright (c) 2014年 wjj. All rights reserved.
//

#import "ViewController.h"
#import "ImageHandler.h"

using namespace cv;


@interface ViewController ()
{
    BOOL format;
    UIImageView *testImageView;
}

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self test];
//    testImageView = [[UIImageView alloc] initWithFrame:CGRectMake(100,100,100,100)];
//	// Do any additional setup after loading the view, typically from a nib.
////    NSString* filename = [[NSBundle mainBundle] pathForResource:@"tiger" ofType:@"png"];
//    UIImage *image = [UIImage imageNamed:@"tiger.png"];
//    UIImage *lionImage = [UIImage imageNamed:@"lion.png"];
//    cv::Mat cvImage1;
//    cv::Mat cvImage2;
//    cv::Mat cvImageNew;
//    UIImageToMat(image, cvImage1);
//    UIImageToMat(lionImage, cvImage2);
////    if (!cvImage.empty())
////    {
//////        cv::imread(,0);
//        cv::Mat gray;
////        cv::cvtColor(cvImage, gray, CV_RGB2GRAY);
////        
//        cv::GaussianBlur(gray, gray, cv::Size(5, 5), 1.2,1.2);
////
////        cv::Mat edges;
////        cv::Canny(gray, edges, 0, 50);
////        
////        cvImage.setTo(cv::Scalar::all(255));
////        cvImage.setTo(cv::Scalar(0, 128, 255, 255), edges);
////        
////        
////    }
////    cvtColor(devilROI, canny, CV_RGB2GRAY);
//    cv::cvtColor(cvImage1, gray, CV_RGB2GRAY);
//    cv::cvtColor(cvImage2, gray, CV_RGB2GRAY);
//    cvImage1.setTo(cv::Scalar::all(255));
//    cvImage2.setTo(cv::Scalar::all(255));
//    cv::addWeighted(cvImage2, 0.7, cvImage1, 0.3, 0.0, cvImageNew,cvImage2.depth());
//    
//    testImageView.image = MatToUIImage(cvImageNew);
//    //Creating Path to Documents-Directory
////    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
////    NSString *documentsDirectory = [paths objectAtIndex:0];
////    NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"tiger.png"];
////    const char* cPath = [filePath cStringUsingEncoding:NSMacOSRomanStringEncoding];
////    
////    const cv::string newPaths = (const cv::string)cPath;
//    
//    //Save as Bitmap to Documents-Directory
//    cv::Mat mat = cv::imread("tiger.png");
//    cv::addWeighted(<#InputArray src1#>, <#double alpha#>, <#InputArray src2#>, <#double beta#>, <#double gamma#>, <#OutputArray dst#>)
//    [self.view addSubview:testImageView];
//    Mat mat;
}

- (void)test
{
    ImageHandler *handler = [[ImageHandler alloc] init];
    [handler mergeImage:[UIImage imageNamed:@"tiger.png"] :0.3 :[UIImage imageNamed:@"lion.png"] :0.7];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
                                        
@end
